@extends('layouts.layouts')
@section('title')
    <title>编辑管理员信息</title>
    <style>
        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }
        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }
        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
    </style>

@endsection

@section('content')
<script src="/js/upload.js" type="text/javascript"></script>    
    <!-- Demo page code -->

    <div class="content">
        <div class="header">
            
            <h1 class="page-title">用户|编辑信息</h1>

        </div>
        <div class="main-content">
            
<ul class="nav nav-tabs">
  <li class="active"><a href="#home" data-toggle="tab">个人资料</a></li>
  <li><a href="#profile" data-toggle="tab">密码</a></li>
</ul>

<div class="row">
  <div class="col-md-4">
    <br>
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="home">
      <form id="tab" method="post" action="{{url('admin/authorupdate')}}">
          <div class="form-group js-reset-image">
             <a href="javascript:;" class="file">编辑头像(200X200)
                <input type="file" class="upload_img cover" name="coverUrl" placeholder="封面图">
            </a>
            @if(strpos($detail->avatar,'http') !== false)
              <img src="{{$detail->avatar}}" style="max-width:200px;max-height:200px;margin-left: 10px;" id="cover_img" />
            @else
              <img src="{{env('IMG_URL')}}{{$detail->avatar}}" id="cover_img" style="max-width:200px;max-height:200px;">
            @endif
            <input type="hidden" class="cover_img" name="avatar" value="{{$detail->avatar}}" />
          </div> 

          <div class="form-group js-reset-image">
             <a href="javascript:;" class="file">推送图片(750X300)
                  <input type="file" class="upload_img explain" name="explainUrl" placeholder="说明图">
              </a>
            @if(strpos($detail->push_cover,'http') !== false)
              <img src="{{$detail->push_cover}}" style="max-width:750px;max-height:300px;" id="explain_img" />
            @else
              <img src="{{env('IMG_URL')}}{{$detail->push_cover}}" id="explain_img" style="max-width:750px;max-height:300px;">
            @endif
            <input type="hidden" class="explain_img" name="push_cover" value="{{$detail->push_cover}}" />
          </div>
        
        <div class="form-group">
          <label>用户名</label>
          <input type="text" name="name" value="{{$detail->name}}" class="form-control">
        </div>
        <div class="form-group">
          <label>邮箱</label>
          <input type="text" name="email" value="{{$detail->email}}" class="form-control">
        </div>
        <div class="form-group">
          <label>备注</label>
          <input type="text" name="remark" value="{{$remark}}" class="form-control">
        </div>
        <div class="form-group">
            <label>状态</label>
            <select name="status" id="DropDownTimezone" class="form-control">
				  <option value="0" @if($detail->status ==0) selected @endif >禁用</option>
				  <option value = "1" @if($detail->status ==1) selected @endif >显示</option>            
            </select>
          </div>
        <div class="form-group">
            <label>性别</label>
            <select name="sex" id="DropDownTimezone" class="form-control">
              @if($detail->sex=='male')
              <option value="male" selected="selected">男</option>
              <option value = "female">女</option>
              @else
              <option value="male">男</option>
              <option value = "female" selected="selected">女</option>
              @endif            
            </select>
        </div>  
		    <input type="hidden" name="id" value="{{$detail->id}}"/>
	      <input type="hidden" name="_token" value="{{csrf_token()}}"/>
        <!-- <input type="hidden" name="avatar" id="avatar" /> -->
 <div class="btn-toolbar list-toolbar">
      <button class="btn btn-primary btn-submit" type="submit"><i class="fa fa-save"></i> 保存</button>
      <a href="{{url('user/det')}}?id={{$detail->id}}" data-toggle="modal" class="btn btn-danger">删除</a>
    </div>
        </form>
      </div>

      <div class="tab-pane fade" id="profile">

        <form id="tab2"  method="post" action="{{url('admin/store')}}">
          <div class="form-group">
            <label>新密码</label>
            <input type="password" name="password" class="form-control">
          </div>
		  	<input type="hidden" name="id" value="{{$detail->id}}"/>
		  	<input type="hidden" name="_token" value="{{csrf_token()}}"/>
		    
          <div>
              <button class="btn btn-primary" type="submit">更新</button>
          </div>
        </form>
      </div>
    </div>


  </div>
</div>
 </div>
</div>
    <!-- <script src="lib/bootstrap/js/bootstrap.js"></script> -->
    <script type="text/javascript">
      var imgUrl = '{{env('IMG_URL')}}';  
      $(".upload_img").UploadImg({
            url : '/course/fileUpload',
            // width : '320',
            //height : '200',
            quality : '0.8', //压缩率，默认值为0.8
            // 如果quality是1 宽和高都未设定 则上传原图
            mixsize : '10000000',
            //type : 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/bmp,image/x-png',
            before : function(blob,className){
//                var className = '#'+className;
//                $(className).attr('src',blob);
            },
            error : function(res){
                $('#img').attr('src','');
                $('#error').html(res);
            },
            success : function(url,className){
                console.log(className);
                // $('#avatar_url').attr('src', imgUrl + url);
                // $('#avatar').val( url);
                var idName = '#'+className;
                var className = '.'+className;
                $(idName).attr('src',imgUrl+url);
                $(className).val(url);
            }
        });


        $("[rel=tooltip]").tooltip();
        $(function() {
            $('.demo-cancel-click').click(function(){return false;});
        });

    </script>
@endsection
